@extends('layouts.layouts')
@section('title')
    <title>后台首页</title>
@endsection
@section('content')
    <div class="content">
        <div class="header">
            <ul class="breadcrumb">
                <li><a href="/finance/flow">平台流水</a></li>
                <li class="active">流水列表</li>
            </ul>
        </div>
        <div class="main-content">
            <div class="btn-toolbar list-toolbar">
                <form class="form-inline" action="" method="get">
                    <div class="form-group">
                        <input type="text" class="form-control" name="name" placeholder="用户" value="{{$userName}}">
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" name="author" placeholder="导师" value="{{$author}}">
                    </div>
                    <div class="form-group">
                        <input type="text" name="start" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="{{$start}}" class="form-control" id="exampleInputEmail3" placeholder="起始时间">
                    </div>
                    <div class="form-group">
                        <input type="text" name="end" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="{{$end}}" class="form-control" id="exampleInputPassword3" placeholder="结束时间">
                    </div>
                    <div class="form-group">
                        <select class="form-control" name="type">
                            <option {{$type === null?'selected':''}} value="">支付方式</option>
                            <option {{$type === '0'?'selected':''}} value="0">余额支付</option>
                            <option {{$type == 1?'selected':''}} value="1">微信支付</option>
                        </select>
                    </div>
                    <button type="submit" class="btn btn-default">筛选</button>
                    <a href="/finance/export?name={{$userName}}&author={{$author}}&start={{$start}}&end={{$end}}&type={{$type}}" class="btn btn-success">导出</a>
                </form>
            </div>
            <div class="row">
                <div class="col-sm-12 col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading no-collapse">流水列表</div>
                        <table class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>付费者</th>
                                <th>导师</th>
                                <th>用户手机号</th>
                                <th>支付方式</th>
                                <th>付款时间</th>
                                <th>金额</th>
                                <th>项目</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($financeRecords as $k => $financeRecord)
                                <?php
                                    $user = App\User::where('id',$financeRecord->user_id)->select('name','mobile')->first();
//
                                ?>
                                <tr>
                                    <td>{{$financeRecord->id}}</td>
                                    <td>{{$user?$user->name:''}}</td>
                                    <td>{{$financeRecord->courseClass?$financeRecord->courseClass->author->name:''}}</td>
                                    <td>{{$user?$user->mobile:''}}</td>
                                    <td>{{\App\Contant\FinanceRecord::trans($financeRecord->payfrom)}}</td>
                                    <td>{{date('Y-m-d H:i:s',strtotime($financeRecord->created_at))}}</td>
                                    <td>{{$financeRecord->money}}</td>
                                    <td>课程:{{$financeRecord->courseClass?$financeRecord->courseClass->title:''}}</td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
                {{$financeRecords->appends(['type'=>$type,'name'=>$userName,'author'=>$author,'start'=>$start,'end'=>$end])->render()}}
        </div>
    </div>
@endsection